package d5_stream;

import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.SocketChannel;
import java.util.Scanner;

public class t8client {
    public static void main(String[] args) throws Exception {
        SocketChannel sChannel = SocketChannel.open(new InetSocketAddress( "127.0.0.1",9999));
        sChannel.configureBlocking(false);
        ByteBuffer buf = ByteBuffer.allocate(1024);
        Scanner scanner = new Scanner(System.in);
        while(true){
            System.out.println("say:");
            String line = scanner.nextLine();
            buf.put(("username:"+line).getBytes());
            buf.flip();
            sChannel.write(buf);
            buf.clear();
        }
    }
}
